package com.cmict.data.bpm.api.task;

import com.cmict.data.bpm.api.task.dto.*;
import com.cmict.data.bpm.enums.ApiConstants;
import com.cmict.data.framework.common.pojo.CommonResult;
import com.cmict.data.framework.common.pojo.PageResult;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Set;

/**
 * 流程任务 Api 接口
 */
@FeignClient(name = ApiConstants.NAME)
@Api(tags = "RPC 服务 - 流程任务")
public interface BpmTaskApi {
    String PREFIX = ApiConstants.PREFIX + "/task";

    /**
     * @param remindId 用户编号
     * @return 实例的编号
     */
    @GetMapping(PREFIX + "/get")
    @ApiOperation("获取taskExt信息")
    @ApiImplicitParam(name = "remindId", value = "remindId", example = "1024", required = true, dataTypeClass = String.class)
    CommonResult<BpmTaskExtDTO> getTaskExt(@RequestParam("remindId")String remindId);

    /**
     * 查看我的待办任务
     * @param userId
     * @param pageVO
     * @return
     */
    @GetMapping(PREFIX + "/todo-page")
    @ApiOperation("获取 Todo 待办任务分页")
    CommonResult<PageResult<BpmTaskTodoPageRespDTO>> getTodoTaskPage(@RequestParam("userId") Long userId, BpmTaskTodoPageReqDTO pageVO);

    /**
     * 查看我的待办任务
     * @param userId
     * @param formId
     * @return
     */
    @GetMapping(PREFIX + "/todo-list")
    @ApiOperation("获取待办流程id列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "userId", example = "1", required = true, dataTypeClass = Long.class),
            @ApiImplicitParam(name = "formId", value = "formId", example = "1024", required = true, dataTypeClass = Long.class)
    })
    CommonResult<List<BpmTaskTodoPageRespDTO>> getTodoTask(@RequestParam("userId") Long userId, @RequestParam("formId") Long formId);
    /**
     * 根据formId获取对应表单表通过流程审批的formRecordId
     *
     * @param formId formID
     * @return 对应表单表的主键id
     */
    @GetMapping(PREFIX + "/approve_record")
    @ApiOperation("根据formId获取对应表单表通过流程审批的formRecordId")
    @ApiImplicitParam(name = "formId", value = "formId", example = "1024", required = true, dataTypeClass = Long.class)
    CommonResult<Set<Integer>> getApproveRecord(@RequestParam("formId")Long formId);

    /**
     * 查询审批通过的记录
     * @param userId
     * @param reqDTO
     */
    @GetMapping(PREFIX + "/done-page")
    @ApiOperation("查询审批通过的任务")
    @ApiImplicitParam(name = "userId", value = "userId", example = "1024", dataTypeClass = Long.class)
    CommonResult<PageResult<BpmTaskDonePageItemRespDTO>> getDoneTaskPage(@RequestParam(value = "userId",required = false) Long userId, BpmTaskDonePageReqDTO reqDTO);

    /**
     * 查询审批通过的记录
     * @param userId
     * @param formId
     */
    @GetMapping(PREFIX + "/done-list")
    @ApiOperation("查询审批通过的任务")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "userId", example = "1", required = true, dataTypeClass = Long.class),
            @ApiImplicitParam(name = "formId", value = "formId", example = "1024", required = true, dataTypeClass = Long.class)
    })
    CommonResult<List<BpmTaskDonePageItemRespDTO>> getDoneTask(@RequestParam(value = "userId") Long userId, @RequestParam(value = "formId") Long formId);

}
